import voice
import time
import threading
from tkinter import *

input_filename = "input.wav"  # 麦克风采集的语音输入
input_filepath = ""  # 输入s文件的path
in_path = input_filepath + input_filename
windows=Tk()

canvas = Canvas(windows,height=500,width=500)




def speechtext():
    speech = voice.get_audio(in_path)
    result = voice.Speech()
    print(result)
    control(result)
  
        



if __name__ == '__main__':
    windows.title("语音控制电风扇开关")
    Button(windows, text="输入语音指令", command=speechtext).pack()
    canvas.pack()
    flag = Label(windows,text='风扇状态：关')
    def control(result):
        if "打开电风扇。" in result:
            flag['text']='风扇状态：开'
            print("打开中。。。")
        elif "关闭电风扇。" in result:
            flag['text']='风扇状态：关'
            print("关闭中。。。")
    flag.pack()
    windows.mainloop()
   
    